package ie.dcu.spca.model.bean;

import ie.dcu.spca.model.Bean;
import ie.dcu.spca.model.dao.BillDao;
import ie.dcu.spca.model.dao.ProductDao;

import java.util.Date;

public class Item extends Bean {
    private int bill_id;
    private int product_id;
    private double count;

    public Item(int id, int bill_id, int product_id, double count,
            Date creat_at, Date update_at, Date delete_at) {
        this.id = id;
        this.bill_id = bill_id;
        this.product_id = product_id;
        this.count = count;
        this.create_at = creat_at;
        this.update_at = update_at;
        this.delete_at = delete_at;
    }

    public Item(int id, int bill_id, int product_id, double count,
            long creat_at, long update_at, long delete_at) {
        this.id = id;
        this.bill_id = bill_id;
        this.product_id = product_id;
        this.count = count;
        this.create_at = new Date(creat_at);
        this.update_at = new Date(update_at);
        this.delete_at = new Date(delete_at);
    }

    public Bill getBill() {
        BillDao bd = new BillDao();
        return (Bill) bd.selectById(this.bill_id);
    }

    public Product getProduct() {
        ProductDao pd = new ProductDao();
        return (Product) pd.selectById(this.product_id);
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getProduct_id() {
        return product_id;
    }

    public void setProduct_id(int product_id) {
        this.product_id = product_id;
    }

    public double getCount() {
        return count;
    }

    public void setCount(double count) {
        this.count = count;
    }

    public Date getCreate_at() {
        return create_at;
    }

    public void setCreate_at(Date creat_at) {
        this.create_at = creat_at;
    }

    public Date getUpdate_at() {
        return update_at;
    }

    public void setUpdate_at(Date update_at) {
        this.update_at = update_at;
    }

    public Date getDelete_at() {
        return delete_at;
    }

    public void setDelete_at(Date delete_at) {
        this.delete_at = delete_at;
    }

    public int getBill_id() {
        return bill_id;
    }

    public void setBill_id(int bill_id) {
        this.bill_id = bill_id;
    }
}
